<template>
  <div>
    <el-table
      :data="this.tableData" border stripe fit empty-text="暂无数据"
      style="width: 100%" height="100%" max-height=700>
      <el-table-column
        prop="jzdw"
        label="捐赠单位" fixed>
      </el-table-column>
      <el-table-column
        prop="rq"
        label="日期">
      </el-table-column>
      <el-table-column
        prop="lx"
        label="类型">
      </el-table-column>
      <el-table-column
        prop="rkwz"
        label="入库物资">
      </el-table-column>
      <el-table-column
        prop="slz"
        label="数量值">
      </el-table-column>
      <el-table-column
        prop="jldw"
        label="计量单位">
      </el-table-column>
      <el-table-column
        prop="je"
        label="金额">
      </el-table-column>
      <el-table-column
        prop="jydh"
        label="交易单号">
      </el-table-column>
    </el-table>
    <center><el-pagination
      @current-change="handleCurrentChange"
      :total="this.total"
      :page-size="10"
      background
      layout="total, prev, pager, next"
      style="position: absolute;bottom:0">
    </el-pagination></center>

  </div>
</template>

<script>
  import axios from 'axios'

  export default {
    name: "Income",

    data() {
      return {
        total: 0,
        currentPage: 1,
        tableData:[],
      }
    },
    props:
      {
        detail_name: {type: String},
        is_show: {type: Boolean}
      },
    methods:
      {
        getData()
        {
          var url = 'http://127.0.0.1:8080/donation_info/';
          var params = {name: '武汉红十字基金会', limit: '20', offset: this.currentPage};
          axios.get(url, {params})
            .then(res => {
              this.total = res.data.pages;
              this.tableData = res.data.data
            })
            .catch(function (error) {
              throw error;
            });
        },
        handleCurrentChange(val) {
          this.currentPage = val;
          this.getData()
        },
        watch:{
          is_show:function(newvalue) {
            if(newvalue){
              this.getData();
            }
          },
        },
      },mounted() {this.getData()
    },
  }
</script>

<style scoped>

</style>
